package com.linewow.xhyy.nihaonew.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.linewow.xhyy.nihaonew.R;
import com.linewow.xhyy.nihaonew.entity.image.ImagesInfo;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by LXR on 2016/10/10.
 */
public class ImagesInfoAdapter extends RecyclerView.Adapter<ImagesInfoAdapter.ImagesInfoViewHolder> {

    private List<ImagesInfo> imagesInfos;
    private Context context;
    private String TAG="ImagesInfoAdapter";

    public ImagesInfoAdapter(List<ImagesInfo> imagesInfos, Context context) {
        this.imagesInfos = imagesInfos;
        this.context = context;
    }

    @Override
    public ImagesInfoViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.item_images_3, null);
        return new ImagesInfoViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ImagesInfoViewHolder holder, int position) {
        ImagesInfo info=imagesInfos.get(position);
        Log.e(TAG,"路径"+info.path);
        Picasso.with(context).load(info.path).error(R.mipmap.err_avatar).fit().into(holder.images3Image);
    }

    @Override
    public int getItemCount() {
        return imagesInfos.size();
    }


    public class ImagesInfoViewHolder extends RecyclerView.ViewHolder {
        ImageView images3Image;
        public ImagesInfoViewHolder(View itemView) {
            super(itemView);
            images3Image= (ImageView) itemView.findViewById(R.id.images_3_image);
        }
    }
}
